<script setup>
import {reactive, ref} from "vue";
import {login} from '@/net';
const formRef = ref()
const form = reactive({
  username:'',
  password:'',
})
const rule =  {
  username:[{
    required:true,message:'请输入用户名'
  }],
  password:[{
    required:true,message:'请输入密码'
  }]
}
function  userLogin(){
  formRef.value.validate((valid)=>{
    if(valid){
      login(form.username,form.password,()=>{})
    }
  })
}
</script>

<template>
  <div style="text-align: center;margin: 0 20px">
    <div style="margin-top: 50px">
      <div style="font-size:50px;font-weight: bold;">登录</div>
      <div style="font-size:25px;color: gray">请输入用户名和密码进行登录</div>
    </div>
    <div>
      <el-form :model="form" :rules="rule" ref="formRef">
        <el-form-item prop="username">
          <el-input v-model="form.username" maxlength="20" type="text" placeholder="用户名">
          </el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input v-model="form.password" type="password" maxlength="20" placeholder="密码">
          </el-input>
        </el-form-item>
      </el-form>
    </div>
    <div style="margin-top: 20px">
      <el-button @click="userLogin()" style="width: 270px;" type="success" plain>立即登录</el-button>
    </div>
  </div>
</template>

<style scoped>

</style>